/*
 * Menu.h
 *
 *  Created on: 2009-10-28
 *      Author: zhujiao
 */

#ifndef MENU_H_
#define MENU_H_
#include <coecntrl.h>
#include <MenuItem.h>


class MMenuObserver
        {
public:
        virtual void NotifyMenuEventOK(TInt aCommand)=0;
        };

class CMenu : public CCoeControl
        {
public:
        CMenu(MMenuObserver* aBserver);
        ~CMenu();


        
        void SetRect(const TRect &aRect);
        void Draw(const TRect& aRect) const;
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
        void ScrollPrev();
        void ScrollNext();
        TInt GetWidth();
        TInt GetHeight();
        TInt GetItemFocusId();
        void SetVisible(TBool aVal);
        TBool IsVisible();
        void SetSelectItemIdx(TInt aIdx);
public:
        void AddMenuItem(const CMenuItem* aMenuItem);
        void RemoveMenuItem(TInt aIdx);
        void RemoveAllMenuItem();
        
private:
    	TInt CountComponentControls() const;
    	CCoeControl* ComponentControl( TInt aIndex ) const;
    	void SizeChanged();
    	
private:
	
        RPointerArray<CMenuItem> iMenuList;
        TInt iFocusControlIdx;
        TRect iParentRect;
        TBool iVisible;
        MMenuObserver* iBserver;
        
public:        
        enum
        {
        ENUM_LEFT,
        ENUM_POP
        };

        };

#endif /* MENU_H_ */
